using HTCollections.Unsafe;
using Unity.Jobs;

namespace HTCollections.Examples.JobSystem
{
    public struct TestJob1 : IJob
    {
        public TestData1 Data1;
        public JobDataWrap<int> Data;

        public void Execute()
        {
            var hashMap = Data1.Map;
            if (hashMap.TryGetValue(Data1.Value1, out int value))
            {
                var subData = Data1.PriorityQueue.Peek();
                if (subData.Enable)
                    Data.Value = subData.IntList[subData.Value1] + value;
                else
                    Data.Value = subData.Value2 + value;
            }
        }
    }

    public struct TestJob2 : IJob
    {
        public JobDataWrap<UnsafeHashMap<int, int>> Map;
        public JobDataWrap<UnsafeList<int>> List;

        public void Execute()
        {
            var lst = List.Value;
            var map = Map.Value;
            if (map.ContainsKey(712))
            {
                map[712] = 905;
                lst[0] = 905;

                map.Add(99, 66);
                lst.Add(99);

                //struct 必须重新赋值
                Map.Value = map;
                List.Value = lst;
            }
        }
    }
}